#include<iostream>
#include<cmath>
using namespace std;


int main() {

	int n, m;
	cin >> n >> m;
	int **a;

	a = new int *[n];
	for (int i = 0; i < n; i++) {
		a[i] = new int [m];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> *(*(a + i) + j);
		}
	}

	int **b;
	b = new int *[n];
	for (int i = 0; i < n; i++) {
		b[i] = new int [m];
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> *(*(b + i) + j);
		}
	}

	int arr[n][m];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			arr[i][j] = (*(*(a + i) + j)) + (*(*(b + i) + j));
			cout << arr[i][j];
			if (j != m - 1) {
				cout << " ";
			}

		}
		if (i != n - 1) {

			cout << endl;	//TODO
		}
	}

	return 0;

}
